/*
 * CMathTables.cpp
 *
 *  Created on: 12.2.2009
 *      Author: jari.ravantti
 */

#include "CMathTables.h"
using namespace std;

CMathTables::CMathTables() {

	m_Sin = new double[360];
	m_Cos = new double[360];
	m_Tan = new double[360];

	for (int m_Angle = 0; m_Angle < 360; m_Angle++) {
		m_Sin[m_Angle] = sin(m_Angle * PI / 180);
		m_Cos[m_Angle] = cos(m_Angle * PI / 180);
		m_Tan[m_Angle] = tan(m_Angle * PI / 180);
	}

}

CMathTables::~CMathTables() {
	delete m_Sin;
	delete m_Cos;
	delete m_Tan;
}

double CMathTables::Sin(int aAngle) {
	if (aAngle >= 0 && aAngle < 361) {
		return m_Sin[aAngle];
	} else {
		return 0;
	}
}
double CMathTables::Cos(int aAngle) {
	if (aAngle >= 0 && aAngle < 361) {
		return m_Cos[aAngle];
	} else {
		return 0;
	}
}
double CMathTables::Tan(int aAngle) {
	if (aAngle >= 0 && aAngle < 361) {
		return m_Tan[aAngle];
	} else {
		return 0;
	}
}
